#include "RastiginFunction.hpp"
#include <cmath>

void RastiginFunction::operator()(Specimen &argument)
{
  long double fx=0.0;

  for (int i = 0; i < _dims; ++i )
    {
      fx += pow(argument[i],2) - cos(18.0*argument[i]);
    }
  
  argument.setFitness(fx);
}

/*
  

  double rastrigin(vector<double> x)
{
	int i, n = x.size();
	double fx = 0.0;

	for ( i = 0; i < n; i++ )
	{
		fx += pow(x[i],2) - cos(18.0*x[i]);
	}

	return fx;
}
*/
